<!--
 * @Author: yaojian66 1327629137@qq.com
 * @Date: 2022-06-24 10:55:49
 * @LastEditors: yaojian66 1327629137@qq.com
 * @LastEditTime: 2022-06-24 11:13:19
 * @FilePath: \geyao\第三十五题 字符串字符统计.html
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>字符串字符统计</title>
</head>
<body>
  <script>
//      统计字符串中每个字符的出现频率，返回一个 Object，key 为统计字符，value 为出现频率
// 1. 不限制 key 的顺序
// 2. 输入的字符串参数不会为空
// 3. 忽略空白字符

function count(str) {
  const m = {}
    for(let k of str){
        if(k === ' ') continue
        if(k in m){
            m[k]++
        } else {
            m[k] = 1
        }
    }
    return m
}
  </script>
</body>
</html>